package com.mazaiting.demo.controller;

import io.micrometer.core.instrument.MeterRegistry;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 监控测试
 * <a href="监控地址:">http://localhost:9200/actuator/prometheus</a>
 * @author mazaiting
 * @create_time 2022/10/5 10:49
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class PrometheusController {

    private final MeterRegistry registry;

    /**
     * 测试监控信息
     * 需要手动调用一下
     * @return 字符串
     */
    @GetMapping("/test")
    public String test() {
        registry.counter("test", "from", "127.0.0.1", "method", "test").increment();
        return "ok";
    }
}
